home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Rice_CMS / gopher24 / gopclitm.$rexx < prev    next >
Encoding:
Text File  |  1993-01-25  |  26.3 KB  |  333 lines

  1. /*                                                                      00010000
  2.  *        Name: GOPCLITM REXX                                           00020000
  3.  *              VM TCP/IP Network GOPHER Client item processor          00030000
  4.  *      Author: Rick Troth, Rice University, Information Systems        00040000
  5.  *        Date: 1992-Dec-23                                             00050000
  6.  *                                                                      00060000
  7.  *       Input: one or more gopher menu lines                           00070000
  8.  *      Output: zero or more information or error messages              00080000
  9.  *              (EOF does not propagate back to input)                  00090000
  10.  */                                                                     00100000
  11.                                                                         00110000
  12. /*                                                                      00120000
  13.  *      Copyright 1992 Richard M. Troth.   This software was developed  00130000
  14.  *      with resources provided by Rice University and is intended      00140000
  15.  *      to serve Rice's user community.   Rice has benefitted greatly   00150000
  16.  *      from the free distribution of software,  therefore distribution 00160000
  17.  *      of unmodified copies of this material is not restricted.        00170000
  18.  *      You may change your own copy as needed.   Neither Rice          00180000
  19.  *      University nor any of its employees or students shall be held   00190000
  20.  *      liable for damages resulting from the use of this software.     00200000
  21.  */                                                                     00210000
  22.                                                                         00220000
  23. Trace "OFF"                                                             00230000
  24.                                                                         00240000
  25. Parse Upper Arg disp . '(' . ')' .                                      00250000
  26. If disp = "" Then disp = "OPEN"                                         00260000
  27. /*  Say open  */                                                        00270000
  28.                                                                         00280000
  29. /*  sync with input so that 'CALLPIPE COMMAND' will work  */            00290000
  30. 'PEEKTO'                                                                00300000
  31.                                                                         00310000
  32. 'CALLPIPE COMMAND GLOBALV SELECT GOPHER GET GOPHER PROGID'              00320000
  33.                                                                         00330000
  34. /*  fetch fs. stem variable from GlobalVs  */                           00340000
  35. 'CALLPIPE COMMAND GLOBALV SELECT GOPHER LIST | DROP' ,                  00350000
  36.         '| LOCATE 1-4 / FS./ | SPEC /=/ 1 2-* NEXT | VARLOAD'           00360000
  37. If ^Datatype(fs.tube,'X') Then fs.tube = ""                             00370000
  38.                                                                         00380000
  39. /*  prepare for dynamic connection statistics  */                       00390000
  40. stat = 'STEM STAT. | GOPCLIST'                                          00400000
  41.                                                                         00410000
  42. Do Forever                                                              00420000
  43.                                                                         00430000
  44.     'PEEKTO ITEM'                                                       00440000
  45.     If rc ^= 0 Then Leave                                               00450000
  46.                                                                         00460000
  47.     'CALLPIPE COMMAND GLOBALV SELECT GOPHER PUT ITEM'                   00470000
  48.                                                                         00480000
  49.     Parse Var item name '05'x path '05'x host '05'x port '05'x xtra     00490000
  50.     Parse Var name 1 type 2 name                                        00500000
  51.                                                                         00510000
  52. stat.0 = 0                                                              00520000
  53.                                                                         00530000
  54.     Select  /*  type  */                                                00540000
  55.                                                                         00550000
  56.         When  type = '0'  Then  Call  OPENFILE                          00560000
  57.                                                                         00570000
  58.         When  type = '1'  Then  Call  OPENMENU                          00580000
  59.                                                                         00590000
  60.         When  type = '2'  Then  Call  LOOKUP                            00600000
  61.                                                                         00610000
  62.         When  type = '4'  Then  Call  OPENFILE  /* MAC */               00620000
  63.                                                                         00630000
  64.         When  type = '5'  Then  Call  OPENFILE  /* DOS */               00640000
  65.                                                                         00650000
  66.         When  type = '6'  Then  Call  OPENFILE  /* UUE */               00660000
  67.                                                                         00670000
  68.         When  type = '7'  Then  Call  SEARCH                            00680000
  69.                                                                         00690000
  70.         When  type = '8'  Then  Call  TELNET                            00700000
  71.                                                                         00710000
  72.         When  type = '9'  Then  Call  BINARY                            00720000
  73.                                                                         00730000
  74.         When  type = 'T'  Then  Call  TN3270                            00740000
  75.                                                                         00750000
  76.         When  type = 'r'  | ,                                           00760000
  77.               type = 'v'  Then  Call  CMSBLOCK                          00770000
  78.                                                                         00780000
  79.         When  type = 'I'  | ,                                           00790000
  80.               type = ':'  | ,                                           00800000
  81.               type = 'g'  Then  Call  GRAPHICS                          00810000
  82.                                                                         00820000
  83.         Otherwise               Call  OPENFILE                          00830000
  84.                                                                         00840000
  85.         End  /*  Select  type  */                                       00850000
  86.                                                                         00860000
  87. If rc ^= 0 Then 'CALLPIPE STEM STAT. | *:'                              00870000
  88.                                                                         00880000
  89.     'READTO'                                                            00890000
  90.                                                                         00900000
  91.     End  /*  Do  Forever  */                                            00910000
  92.                                                                         00920000
  93. Exit rc * (rc ^= 12)                                                    00930000
  94.                                                                         00940000
  95.                                                                         00950000
  96.                                                                         00960000
  97. /* ------------------------------------------------------------ OPENFILE00970000
  98.  *  View or retrieve a plain text file.                                 00980000
  99.  */                                                                     00990000
  100. OPENFILE:                                                               01000000
  101.                                                                         01010000
  102. filter = 'GOPCLITX'                                                     01020000
  103.                                                                         01030000
  104. If disp = "KEEP" Then Signal KEEPFILE                                   01040000
  105.                                                                         01050000
  106. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,                             01060000
  107.     '| GOPCLITX | GOPCLIFV | *:' ,                                      01070000
  108.     '! E: |' stat                                                       01080000
  109.                                                                         01090000
  110. Return                                                                  01100000
  111.                                                                         01110000
  112.                                                                         01120000
  113.                                                                         01130000
  114. /* ------------------------------------------------------------ OPENMENU01140000
  115.  *  View or retrieve a plain text file.                                 01150000
  116.  */                                                                     01160000
  117. OPENMENU:                                                               01170000
  118.                                                                         01180000
  119. filter = 'GOPCLITX'                                                     01190000
  120.                                                                         01200000
  121. If disp = "KEEP" Then Signal KEEPFILE                                   01210000
  122.                                                                         01220000
  123. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,                             01230000
  124.     '| GOPCLITX | GOPCLIMB | *:' ,                                      01240000
  125.     '! E: |' stat                                                       01250000
  126.                                                                         01260000
  127. Return                                                                  01270000
  128.                                                                         01280000
  129.                                                                         01290000
  130.                                                                         01300000
  131. /* -------------------------------------------------------------- LOOKUP01310000
  132.  *  Perform user lookup.   (punt to PH EXEC or equivalent)              01320000
  133.  */                                                                     01330000
  134. LOOKUP:                                                                 01340000
  135.                                                                         01350000
  136. host = Strip(host)                                                      01360000
  137. port = Strip(port)                                                      01370000
  138. 'CALLPIPE COMMAND GLOBALV SELECT PHCMS PUT HOST PORT'                   01380000
  139. Address "CMS" 'PH'                                                      01390000
  140.                                                                         01400000
  141. Return                                                                  01410000
  142.                                                                         01420000
  143.                                                                         01430000
  144.                                                                         01440000
  145. /* -------------------------------------------------------------- SEARCH01450000
  146.  */                                                                     01460000
  147. SEARCH:                                                                 01470000
  148.                                                                         01480000
  149. 'CALLPIPE COMMAND XMITMSG 601 (APPLID GOP NOHEADER' ,                   01490000
  150.         '| GOPCLIUI | VAR KEYWORDS'                                     01500000
  151. keywords = Strip(keywords)                                              01510000
  152. If keywords = "" Then Return                                            01520000
  153.                                                                         01530000
  154. /*  prepend a  path<TAB>  to search string for WAIS servers  */         01540000
  155. /*  path = path || '05'x || keywords  */                                01550000
  156. item = item || '05'x || keywords                                        01560000
  157.                                                                         01570000
  158. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,                             01580000
  159.     '| GOPCLITX | GOPCLIMB | *:'                                        01590000
  160.     '! E: |' stat                                                       01600000
  161.                                                                         01610000
  162. Return                                                                  01620000
  163.                                                                         01630000
  164.                                                                         01640000
  165.                                                                         01650000
  166. /* -------------------------------------------------------------- TELNET01660000
  167.  */                                                                     01670000
  168. TELNET:                                                                 01680000
  169.                                                                         01690000
  170. If fs.tube ^= "" Then Do                                                01700000
  171.     /*  'OUTPUT' "Can't TELNET from this screen"  */                    01710000
  172.     'CALLPIPE COMMAND XMITMSG 512 "TELNET"' ,                           01720000
  173.             '(APPLID GOP CALLER CLI ERRMSG | *:'                        01730000
  174.     Return                                                              01740000
  175.     End /* If .. Do */                                                  01750000
  176.                                                                         01760000
  177. Address "COMMAND"                                                       01770000
  178.                                                                         01780000
  179. 'VMFCLEAR'                                                              01790000
  180. If port = 0 Then port = ""                                              01800000
  181. /*  Say progid "TELNET" host port  */                                   01810000
  182. 'XMITMSG 30 HOST PORT (APPLID GOP CALLER CLI ERRMSG'                    01820000
  183. /*  Say name  */                                                        01830000
  184. 'XMITMSG 7 NAME (APPLID GOP CALLER CLI ERRMSG NOCOMP'                   01840000
  185.                                                                         01850000
  186. If path ^= "" Then Do                                                   01860000
  187.     /*  Say "login with:" path  */                                      01870000
  188.     'XMITMSG 32 PATH (APPLID GOP CALLER CLI NOHEADER'                   01880000
  189.     /*  Say "Press ENTER to continue ... "  */                          01890000
  190.     'XMITMSG 33 (APPLID GOP CALLER CLI NOHEADER'                        01900000
  191.     Parse External                                                      01910000
  192.     End  /*  If  ..  Do  */                                             01920000
  193.                                                                         01930000
  194. 'GLOBALV SELECT GOPHER GET TELNET'                                      01940000
  195. If telnet = "" Then telnet = "TELNET"                                   01950000
  196. Address "CMS" telnet host port                                          01960000
  197. 'VMFCLEAR'                                                              01970000
  198.                                                                         01980000
  199. Address                                                                 01990000
  200.                                                                         02000000
  201. Return                                                                  02010000
  202.                                                                         02020000
  203.                                                                         02030000
  204.                                                                         02040000
  205. /* -------------------------------------------------------------- BINARY02050000
  206.  *  Load a "binary" (byte stream) file onto disk.                       02060000
  207.  */                                                                     02070000
  208. BINARY:                                                                 02080000
  209.                                                                         02090000
  210. filter = ""                                                             02100000
  211.                                                                         02110000
  212. If disp = "KEEP" Then Signal KEEPFILE                                   02120000
  213.                                                                         02130000
  214. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,                             02140000
  215.     '| GOPCLIFV | *:' ,                                                 02150000
  216.     '! E: |' stat                                                       02160000
  217.                                                                         02170000
  218. Return                                                                  02180000
  219.                                                                         02190000
  220.                                                                         02200000
  221.                                                                         02210000
  222. /* -------------------------------------------------------------- TN327002220000
  223.  *  This is almost exactly the same as the  TELNET  routine,            02230000
  224.  *  but we let the user run a different program,  specified in          02240000
  225.  *  global variable  TN3270,  if they wish.                             02250000
  226.  */                                                                     02260000
  227. TN3270:                                                                 02270000
  228.                                                                         02280000
  229. If fs.tube ^= "" Then Do                                                02290000
  230.     /*  'OUTPUT' "Can't TN3270 from this screen"  */                    02300000
  231.     'CALLPIPE COMMAND XMITMSG 512 "TN3270"' ,                           02310000
  232.             '(APPLID GOP CALLER CLI ERRMSG | *:'                        02320000
  233.     Return                                                              02330000
  234.     End /* If .. Do */                                                  02340000
  235.                                                                         02350000
  236. Address "COMMAND"                                                       02360000
  237.                                                                         02370000
  238. 'VMFCLEAR'                                                              02380000
  239. If port = 0 Then port = ""                                              02390000
  240. /*  Say progid "TN3270" host port  */                                   02400000
  241. 'XMITMSG 31 HOST PORT (APPLID GOP CALLER CLI ERRMSG'                    02410000
  242. /*  Say name  */                                                        02420000
  243. 'XMITMSG 7 NAME (APPLID GOP CALLER CLI ERRMSG NOCOMP'                   02430000
  244. If path ^= "" Then Do                                                   02440000
  245.     /*  Say "login with:" path  */                                      02450000
  246.     'XMITMSG 32 PATH (APPLID GOP CALLER CLI NOHEADER'                   02460000
  247.     /*  Say "Press ENTER to continue ... "  */                          02470000
  248.     'XMITMSG 33 (APPLID GOP CALLER CLI NOHEADER'                        02480000
  249.     Parse External                                                      02490000
  250.     End  /*  If  ..  Do  */                                             02500000
  251.                                                                         02510000
  252. 'GLOBALV SELECT GOPHER GET TN3270'                                      02520000
  253. If tn3270 = "" Then Do                                                  02530000
  254.     'GLOBALV SELECT GOPHER GET TELNET'                                  02540000
  255.     If telnet = "" Then telnet = "TELNET"                               02550000
  256.     tn3270 = telnet                                                     02560000
  257.     End  /*  If  ..  Do  */                                             02570000
  258. Address "CMS" tn3270 host port                                          02580000
  259. 'VMFCLEAR'                                                              02590000
  260.                                                                         02600000
  261. Address                                                                 02610000
  262.                                                                         02620000
  263. Return                                                                  02630000
  264.                                                                         02640000
  265.                                                                         02650000
  266.                                                                         02660000
  267. /* ------------------------------------------------------------ CMSBLOCK02670000
  268.  *  Save a record oriented file (type 'r' or type 'v') onto disk.       02680000
  269.  */                                                                     02690000
  270. CMSBLOCK:                                                               02700000
  271.                                                                         02710000
  272. filter = 'DEBLOCK CMS'                                                  02720000
  273.                                                                         02730000
  274. If disp = "KEEP" Then Signal KEEPFILE                                   02740000
  275.                                                                         02750000
  276. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,                             02760000
  277.     '| DEBLOCK CMS | GOPCLIFV | *:' ,                                   02770000
  278.     '! E: |' stat                                                       02780000
  279.                                                                         02790000
  280. Return                                                                  02800000
  281.                                                                         02810000
  282.                                                                         02820000
  283.                                                                         02830000
  284. /* ------------------------------------------------------------ GRAPHICS02840000
  285.  *  Display or save a graphics (type 'I') file.                         02850000
  286.  */                                                                     02860000
  287. GRAPHICS:                                                               02870000
  288.                                                                         02880000
  289. filter = ""     /*  same as for  "binary"  files  */                    02890000
  290.                                                                         02900000
  291. If disp = "KEEP" Then Signal KEEPFILE                                   02910000
  292.                                                                         02920000
  293. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,                             02930000
  294.         '| GOPCLIGV | *: ! E: |' stat                                   02940000
  295.                                                                         02950000
  296. Return                                                                  02960000
  297.                                                                         02970000
  298.                                                                         02980000
  299.                                                                         02990000
  300. /* ------------------------------------------------------------ KEEPFILE03000000
  301.  *  Save the selected file on disk.                                     03010000
  302.  */                                                                     03020000
  303. KEEPFILE:                                                               03030000
  304.                                                                         03040000
  305. If fs.tube ^= "" Then Do                                                03050000
  306.     'CALLPIPE COMMAND XMITMSG 508 (APPLID GOP CALLER CLI ERRMSG | *:'   03060000
  307.     Return                                                              03070000
  308.     End  /*  If  ..  Do  */                                             03080000
  309.                                                                         03090000
  310. Parse Var path 1 . 2 path    /*  discard type indicator  */             03100000
  311. file = gopclifi(path)                                                   03110000
  312. 'CALLPIPE CMS STATE' file 'A | VAR NOTFOUND'                            03120000
  313. If rc ^= 0 & rc ^= 28 Then 'CALLPIPE VAR NOTFOUND | *:'                 03130000
  314. If rc = 0 Then 'CALLPIPE COMMAND XMITMSG 594 FILE' ,                    03140000
  315.         '(APPLID GOP CALLER CLI ERRMSG | *:'                            03150000
  316. If rc ^= 28 Then Return                                                 03160000
  317.                                                                         03170000
  318. If filter = "" Then                                                     03180000
  319. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,                             03190000
  320.         '| >' file 'A' ,                                                03200000
  321.         '! E: |' stat                                                   03210000
  322. Else                                                                    03220000
  323. 'CALLPIPE (END !) VAR ITEM | E: GOPCLISX' ,                             03230000
  324.         '|' filter '| >' file 'A' ,                                     03240000
  325.         '! E: |' stat                                                   03250000
  326.                                                                         03260000
  327. If rc = 0 Then 'CALLPIPE COMMAND XMITMSG 571 FILE PATH' ,               03270000
  328.         '(APPLID GOP CALLER CLI ERRMSG | *:'                            03280000
  329. /*  If rc = 0 Then errmsg = "Created" fn ft fm "from" path  */          03290000
  330.                                                                         03300000
  331. Return                                                                  03310000
  332.                                                                         03320000
  333.